from django.db import models

# Create your models here.


class OrderInfo(models.Model):
    order_id = models.CharField(max_length=100, verbose_name="订单号")
    user_id = models.CharField(max_length=100, verbose_name="用户id")
    address_id = models.CharField(max_length=100, verbose_name="地址id")
    price = models.CharField(max_length=255, verbose_name="商品总价", default="", null=True)
    goods_info = models.TextField()
    key_id = models.CharField(max_length=10, verbose_name="同一个订单")
    status = models.CharField(max_length=2, verbose_name="订单状态")
    order_time = models.CharField(max_length=20, verbose_name="订单时间")
    num = models.CharField(max_length=10, verbose_name="商品数量", default="", null=True)

    # 配置模型元数据
    class Meta:
        ordering = ["id"]  # 根据id进行排序
        db_table = "order"  # 创建的表名
        verbose_name = "订单表"  # 当前表的别名
        verbose_name_plural = verbose_name

    def __str__(self):
        return '%s:%s' % (self.order_id, self.user_id)
